<template>
	<view class="outside">
		<view v-for="(item,index) in dataArray" class="item" @click="changeIndex(index)">
			<text :class="nowIndex==index?'name on':'name off'">{{item}}</text>
			<view class="center"></view>
			<view :class="index == nowIndex?'slider on-slider':'slider off-slider'"></view>
		</view>
		<view class="bottom"></view>

	</view>
</template>

<script>
	export default {
		props: {
			dataArray: Array,
			checkedIndex: Number
		},
		data() {
			return {
				nowIndex: this.checkedIndex
			}
		},
		onLoad() {
			this.left = this.leftList[0]
		},
		methods: {
			changeIndex(index) {
				this.nowIndex = index
				this.$emit('handleIndexChange', index)
			}
		},
	}
</script>

<style>
	.bottom {
		position: absolute;
		bottom: 0;
		left: 0;
		width: 100%;
		height: 10rpx;
		background: #ddd;
	}

	.slider {
		position: relative;
		height: 10rpx;
		z-index: 10;
		border-radius: 5rpx;
		background: #333;
		width: 120rpx;
	}

	.outside {
		position: relative;
		/* padding: 20rpx 0; */
		/* height: 180rpx; */
		width: 100%;
		display: flex;
		align-items: center;
		justify-content: space-around;
	}


	.item {
		position: relative;
		flex: 1;
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
		/* display: inline-block; */
		/* height: 78rpx; */
		width: 180rpx;
		text-align: center;
		/* border-left: #ddd solid 1rpx; */
		/* border-right: #ddd solid 1rpx; */
	}

	.name {
		display: inline-block;
		width: auto;
		height: 80rpx;
		font-size: 32rpx;
		line-height: 80rpx;
		/* display: inline-block; */
	}

	.on {
		color: #333;
		/* border-bottom: #333 solid 10rpx; */
	}

	.off {
		color: #999;
		/* border-bottom: #fff solid 10rpx; */
	}
	
	.on-slider{
		background: #333 !important;
	}
	.off-slider{
		background: #ddd !important;
	}

	.center {
		position: absolute;
		right: 0;
		top: 22rpx;
		height: 36rpx;
		width: 2rpx;
		background: #ddd;
		z-index: 99;
	}
</style>
